package cn.pugle.base.collect;

import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.Map;

/**
 * @author tzp
 * @since 2020/11/4
 */
public class LinkedHashMapApp {
    public static void main(String[] args) {
        LinkedHashMap<String, String> a = new LinkedHashMap<String, String>() {
            @Override
            protected boolean removeEldestEntry(Map.Entry<String, String> eldest) {
                return size() > 2;
            }
        };
        a.put("a", "a");
        a.put("b", "a");
        a.put("c", "a");
        for (Map.Entry<String, String> e : a.entrySet()) {
            System.out.println(e.getKey());
        }
    }
}
